"""
读图不能按原来的写
二进制也可打开文本文件
"""
# file = open(r"D:\desk\绘画\素材\美女.webp",mode='r+',encoding='utf8')
# text = file.read()
# print(text)

#打开不是文本的文件都用二进制（b）模式
file = open(r"D:\desk\绘画\素材\美女.webp",mode='rb+')
file_write = open('text1.jpg',mode='wb')
bytes_file = file.read()
file_write.write(bytes_file)
file.close()
file_write.close()
# print(text)

#r打开文本文件，rb打开文本文件

def use_rb():
    file = open('file1.txt', mode='r+', encoding='utf8')

    text = file.read()
    print(len(text))
    print(text)

def use_rbb():
    file = open('file1.txt', mode='rb+')
    #读出的是字节流bytes
    text = file.read()
    print(len(text))
    print(text)
    #二进制模式下读出换行符\r\n
    #文本模式下换行符\r\n会自动读成\n

use_rb()
print('-'*50)
use_rbb()





